﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using MaxLeaf.DB;
using System.Data;
using MySql.Data.MySqlClient;

namespace MaxLeaf.DAL.K2W
{
   


    public class t_UnitGroupDAL : BaseDAL
    {
        public t_UnitGroupDAL()
            : base()
        {
            strTableName = "goods_unit_group";
            strOrgTableName = "t_UnitGroup";

            strKeyFieldName = "unit_group_id";
            strOrgKeyFieldName = "FUnitGroupID";

            strFieldNames = "group_name";
            strOrgFieldNames = "fname";
        }

        public override int Update(DBAccess dbOrgK3Con, DBAccess dbDestWebReadCon, DBAccess dbDestWebWriteCon, string strKeyValue)
        {
            int intDestKey = base.Update(dbOrgK3Con, dbDestWebReadCon, dbDestWebWriteCon, strKeyValue);

            if (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["SCP"]))
            {
                //Web 2 SCP
                string strSQL = @"insert into SCP_mLog(logtype,keyvalue,logstatus)
                values(?logtype,?keyvalue,?logstatus)";
                dbDestWebWriteCon.ExecuteSql(strSQL, new MySqlParameter[] { 
                    new MySqlParameter("?logtype", "goods_unit_group") 
                    ,new MySqlParameter("?keyvalue",  intDestKey.ToString()) 
                    ,new MySqlParameter("?logstatus", "1") 
                });
            }
            return intDestKey;
        }
        
    }
}